@extends('home.index.layout')

@section('content')
<script src="{{url('/ho/js/event.js')}}"></script>
<link href="{{url('/ho/css/themes.css')}}" rel="stylesheet" type="text/css">
<div class="wrap">
        <!--面包屑-->
        <div class="crumbs"><a class="ml0" href="{{url('/')}}">首页</a>&gt;<a href="{{url('/home/user/space')}}" class="j_ygnav">我的易果</a><span class="j_thridcrumbs hide">&gt;<a href="javascript:void(0)" class="on j_thirdnav"></a></span></div>
    <div class="content myyg">
            <div class="sub">
                <div class="menu j_menu">
                    <dl>
                        <dt>交易信息</dt>
                        <dd>
                            <ul>
                                <li><a href="{{url('/order/index')}}">我的订单</a></li>
                                
                                <li><a href="">我的金币</a></li>
                                
                                
                                
                                <li><a href="">购买过的商品</a></li>
                                <li><a href="{{url('/user/favorite')}}">我的收藏</a></li>
                                <li><a href="">评论商品</a></li>
                            </ul>
                        </dd>
                        <dt>账号信息</dt>
                        <dd>
                            <ul>
                                <li><a href="">账户余额</a></li>
                                <li>
                                    <a href="{{url('/user/detail')}}">个人资料</a>
                                        <img style="height: 19px; width: 20px; margin-left: 10px;" src="{{url('/ho/imgs/icon-gift.png')}}">
                                </li>
                                <li><a href="">账号安全</a></li>
                                <li><a href="{{url('/user/address')}}">收货地址管理</a></li>
                                

                                                
                                
                                
                            </ul>
                        </dd>
                        <dt>售后服务</dt>
                        <dd>
                            <ul>
                                <li><a href="">在线退换货</a></li>
                                <li><a href="">投诉建议</a></li>
                            </ul>
                        </dd>
                    </dl>
                </div>
                <div>
                    <div class="ad" style="height: 308px;">
                        <a href="#" target="_blank" style="display: none"><img src="{{url('/ho/imgs/ad.jpg')}}" width="194" height="308"></a>
                    </div>
                </div>
            </div>

        <div class="main">

            <div class="user-info   clearfix">
                <div class="info-lcol">
                    <div class="u-pic">
                        <img alt="用户头像" src="{{url('/uploads/yhtx')}}/{{session('home')->pic ? session('home')->pic :"default.jpg"}}" style="width:90px;height:90px;">
                        <div class="mask"></div>
                    </div>
                    <div class="info-m">
                        <div class="u-name">
                            <a class="name" href="" target="_blank">{{session('home')->email}}</a><a class="modify " href="">修改</a>
                        </div>
                        <div class="u-level">
                            <div class="vip">
                                <div class="grade"><i></i>易果生鲜普通用户</div>
                                <div class="grade-line"><span><i style="width:0%"></i></span></div>
                            </div>

                                        <a class="vip-info" href="">查看会员等级制度</a>

                        </div>
                    </div>
                    <div class="u-safe">
                        <div class="safe-rank">账户安全等级:<b>高</b><a href="#">提升</a></div>
                        <div class="tel"><i></i>手机:<a href="#">{{session('home')->phone ? session('home')->phone : ''}}</a></div>
                        <div class="e-mail"><i></i>邮箱: <a href="#">{{session('home')->email}}</a></div>
                    </div>
                    <div class="info-line"></div>
                </div>
                <div class="info-rcol">
                    <ul class="acco-info">
                        <li class="balance">
                            <h4><i></i>账户余额</h4>
                            <div class="num"><b title="¥0.00">¥0.00</b></div>
                            <div><a href="#">充值</a></div>
                        </li>
                        <li class="yb">
                            <h4><i></i> 悠币</h4>
                            <div class="num"><b>{{session('home')->gold}}</b></div>
                            <div><a href="#">兑换</a></div>
                        </li>
                        
                    </ul>
                </div>
            </div>
            <div class="mod-order clearfix">
                <div class="table-title"><h3>我的订单</h3><a class="all" href="">查看全部订单</a></div>
                    @if($res)
                                    <!-- {{$i = 0}} -->
                    @foreach($orders as $k => $t)
                    {{--dd($t[0] -> id)--}}
                        <div>
                            <div class="title">
                                <span>订单号:</span>
                                <span class="order_num">{{$k}}</span> &nbsp; &nbsp;  
                            </div>
                            <div class="list">
                                    <!-- {{$j = 0}} -->
                                    @foreach($data as $o[$j])
                                    @if($o[$j] -> order_num == $k)
                                <table  class="gridtable">
                                    <tr>
                                        <td>{{$o[$j] -> gname}}</td>
                                        <td>{{$o[$j] -> gprice}}元</td>
                                        <td>数量：{{$o[$j] ->count}} 件</td>
                                        <td>{{$o[$j] -> order_status == 0 ? '待发货' : ($o[$j] -> order_status == 1?'配送中':'已签收')}}</td>
                                        <td class="order_status" num="{{$k}}">{{$o[$j] -> order_status > 1?'已完成':'确认收货'}}</td>
                                    </tr>
                                            
                                    <!-- {{$j++}} -->
                                </table>
                                    @endif
                                    @endforeach
                            </div>
                        </div>
                                    <!-- {{$i++}} -->
                    @endforeach
                    @else
                        <tbody><div class="order-none">亲爱的易果用户，您目前尚无记录呦～<a href="{{url('/')}}">快去逛逛吧</a>～</div></tbody>
                    @endif
                    
            </div>
         

        </div>

    </div>

</div>
 <script type="text/javascript">
        window.onload = function()
        {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $('.order_status').on('click', function()
            {
                // alert(111);
                //获取当前对象
                var t = $(this);
                var order_num = $(this).attr('num');
                // alert(order_num);
                $.ajax({
                    type:"GET",
                    url:"{{ asset('/user/status') }}",
                    data:{order_num:order_num},
                    success:function(data)
                    {
                        // console.log(data);
                       if(data == 2)
                       {
                            // alert(2)
                            t.html('已完成');
                       }
                    },
                    error:function()
                    {
                        alert('异常');
                    }
                });
            });

        
        }
    </script>
@endsection